.ng-select-container {
  position: relative;
  width: 100%;
  font-size: 14px;
  color: #333;
  user-select: none;

  * {
    box-sizing: border-box;
  }

  // 单选模式
  .ng-select-single {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 30px 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      border-color: #40a9ff;
    }

    .ng-select-placeholder {
      color: #bfbfbf;
    }

    .ng-select-value {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .ng-select-clear {
      position: absolute;
      right: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.3s;

      .clear-icon {
        font-size: 16px;
        font-style: normal;
        color: #999;

        &:hover {
          color: #666;
        }
      }
    }

    &:hover .ng-select-clear {
      opacity: 1;
    }

    .ng-select-arrow {
      position: absolute;
      right: 12px;
      display: flex;
      align-items: center;
      justify-content: center;

      .arrow-icon {
        font-size: 12px;
        font-style: normal;
        color: #999;
        transition: transform 0.3s;

        &.arrow-up {
          transform: rotate(180deg);
        }
      }
    }
  }

  // 多选模式
  .ng-select-multiple {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 30px 4px 4px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      border-color: #40a9ff;
    }

    .ng-select-tags {
      flex: 1;
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      align-items: center;
      min-height: 28px;

      .ng-select-tag {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 2px 8px;
        background-color: #f5f5f5;
        border: 1px solid #e8e8e8;
        border-radius: 2px;
        font-size: 12px;
        color: #333;

        .tag-close {
          font-size: 14px;
          font-style: normal;
          color: #999;
          cursor: pointer;
          transition: color 0.3s;

          &:hover {
            color: #333;
          }
        }
      }

      .ng-select-search-input {
        flex: 1;
        min-width: 80px;
        height: 28px;
        padding: 4px 8px;
        border: none;
        outline: none;
        font-size: 14px;

        &::placeholder {
          color: #bfbfbf;
        }
      }
    }

    .ng-select-clear {
      position: absolute;
      right: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.3s;
      z-index: 1;

      .clear-icon {
        font-size: 16px;
        font-style: normal;
        color: #999;

        &:hover {
          color: #666;
        }
      }
    }

    &:hover .ng-select-clear {
      opacity: 1;
    }

    .ng-select-arrow {
      position: absolute;
      right: 12px;
      display: flex;
      align-items: center;
      justify-content: center;

      .arrow-icon {
        font-size: 12px;
        font-style: normal;
        color: #999;
        transition: transform 0.3s;

        &.arrow-up {
          transform: rotate(180deg);
        }
      }
    }
  }

  // 下拉菜单
  .ng-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 300px;
    background-color: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    overflow: hidden;

    .ng-select-search {
      padding: 8px;
      border-bottom: 1px solid #f0f0f0;

      .ng-select-search-input {
        width: 100%;
        height: 32px;
        padding: 4px 12px;
        border: 1px solid #d9d9d9;
        border-radius: 4px;
        outline: none;
        font-size: 14px;
        transition: border-color 0.3s;

        &:focus {
          border-color: #40a9ff;
        }

        &::placeholder {
          color: #bfbfbf;
        }
      }
    }

    .ng-select-loading,
    .ng-select-empty {
      padding: 12px;
      text-align: center;
      color: #999;
      font-size: 14px;
    }

    .ng-select-options {
      margin: 0;
      padding: 4px 0;
      list-style: none;
      max-height: 256px;
      overflow-y: auto;

      .ng-select-option {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        cursor: pointer;
        transition: background-color 0.3s;

        &:hover {
          background-color: #f5f5f5;
        }

        &.selected {
          background-color: #e6f7ff;
          color: #1890ff;
        }

        &.disabled {
          color: #bfbfbf;
          cursor: not-allowed;

          &:hover {
            background-color: transparent;
          }
        }

        .option-checkbox {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 16px;
          height: 16px;
          border: 1px solid #d9d9d9;
          border-radius: 2px;
          transition: all 0.3s;

          .checkbox-icon {
            font-size: 12px;
            font-style: normal;
            color: #1890ff;
          }
        }

        &.selected .option-checkbox {
          background-color: #1890ff;
          border-color: #1890ff;

          .checkbox-icon {
            color: #fff;
          }
        }

        .option-label {
          flex: 1;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;

          // 高亮搜索关键字
          .search-highlight {
            background-color: #fffb8f;
            color: #d46b08;
            font-weight: 500;
          }
        }
      }
    }
  }

  // 禁用状态
  &.disabled {
    .ng-select-single,
    .ng-select-multiple {
      background-color: #f5f5f5;
      cursor: not-allowed;

      &:hover {
        border-color: #d9d9d9;
      }
    }
  }
}

// 滚动条样式
.ng-select-options::-webkit-scrollbar {
  width: 6px;
}

.ng-select-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.ng-select-options::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;

  &:hover {
    background: #a8a8a8;
  }
}
